package org.vectrics.user.dataweb;

import javax.servlet.http.HttpServletRequest;

import org.vectrics.dataweb.WebService;
import org.vectrics.dataweb.WebServiceAction;
import org.vectrics.struts.Request;
import org.vectrics.SystemException;
import org.vectrics.VectricsException;
import org.apache.log4j.Logger;
import org.w3c.dom.Element;


public class UserWebAction extends WebServiceAction {
	static private transient Logger log = Logger.getLogger(UserWebAction.class);
	static private String COMMAND_NOT_FOUND = "Command not found or not given: ";	
	
	public UserWebAction() {
		super();
	}


	public void getData(Request request, String command, Element requestData, 
				Element dataElement) {
		WebService action = null;
		if (command == null) {
			action = null;
		}
		else if (command.equals("findUserName")) {
			log.debug("getData() - name search action");
			action = new NameSearchAction();
		}		
		else if (command.equals("findUserDetails")) {
			log.debug("getData() - details search action");
			action = new FindUserDetailsAction();
		}		
		else if (command.equals("updateUser")) {
			log.debug("getData() - update action");
			action = new UpdateUserAction();
		}		
		
		if (action == null) {
			throw new SystemException("Command not found, command = " + command);
		} else {
			log.debug("getData() - action found, getting data");
			action.getData(request, command, requestData, dataElement);	
		}
	}
	
}

